package com.angel.adapter;

import java.util.List;

import com.angel.activity.R;
import com.angel.entity.WillBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/** 自定义配器Adapter */
public class WilAdapter extends BaseAdapter {

	private Context context = null;
	private List<WillBean> wilEntityList=null;
	/**
	 * 自定义构造
	 * 
	 * @param activity
	 * @param handler
	 * @param list
	 */
	public WilAdapter(Context context,List<WillBean> wilEntityList) {
		this.context = context;
		this.wilEntityList=wilEntityList;
	}

	@Override
	public int getCount() {
		
		return wilEntityList.size()==0?0:wilEntityList.size();
	}

	@Override
	public Object getItem(int position) {
		return wilEntityList==null?null:wilEntityList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		WilViewHolder holder = null;
		if (convertView == null) {
			holder = new WilViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.wil_item, null);
			/*设置意愿内容*/
			holder.wil_comtextView = (TextView) convertView
					.findViewById(R.id.wil_com);
			holder.wil_comtextView.setText(wilEntityList.get(position).getWillContent());
			/*设置意愿时间*/
			holder.wil_timetextView = (TextView) convertView
					.findViewById(R.id.wil_time);
			holder.wil_timetextView.setText(wilEntityList.get(position).getIdeaTime());
			/*设置活动类型*/
			holder.wil_timetextView = (TextView) convertView
					.findViewById(R.id.wil_type);
			holder.wil_timetextView.setText(wilEntityList.get(position).getType());
			
			convertView.setTag(holder);
		} else {
			holder = (WilViewHolder) convertView.getTag();
		}

		return convertView;
	}
}

 class WilViewHolder {
	TextView wil_comtextView;//活动具体内容
	TextView wil_timetextView;//活动时间
	TextView wil_typetextView;//活动类型
}
